package com.song.demo;

/**
 * @author TonySong
 * @date 2024/6/6 0006
 * @time 15:27
 */
public class A {

  static ThreadLocal<A> threadLocal = new ThreadLocal<>();

    private A(){}
    private static A a;

    public static A getInstance(){
        A a = threadLocal.get();
        if(a == null){
            a=new A();
            threadLocal.set(a);
        }
        return  a;
    }

    public static void main(String[] args) {
         for(int i=0;i<10;i++){
             System.out.println(A.getInstance());
         }

    }

//    public static  A getInstance(){
//        if(a == null){
//            a = new A();
//        }
//        return a;
//    }

}
